home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK1.toast / Development Kits (Disc 1) / AOCE / Development Tools / Sample Code / Standard Catalog Package / DTS AddressOMatic / Src / AddressOMaticTest.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-10-20  |  8.9 KB  |  352 lines  |  [TEXT/KAHL]

  1. /*                                AddressOMaticTest.h                                */
  2. /*
  3.  * AddressOMaticTest.h
  4.  * Copyright © 1993 Apple Computer Inc. All rights reserved.
  5.  */
  6. #ifndef _AddressOMaticTest_
  7. #define _AddressOMaticTest_
  8. /*
  9.  * These definitions are common to ReZ and code sources.
  10.  */
  11. #ifdef THINK_Rez
  12. #define kApplicationCreator            '????'
  13. #else
  14. #define kApplicationCreator         '???\?'
  15. #endif
  16. #define kApplicationType            'APPL'
  17. #define ALRT_NonFatal                (9000)
  18. #define ALRT_Fatal                    (9010)
  19. #define ALRT_Continue                (9020)
  20. #define ALRT_Info                    (9030)
  21.  
  22. #define MBAR_MenuBar                (1)
  23. #define MENU_Apple                    (1)
  24. #define MENU_File                    (256)
  25. #define MENU_Edit                    (257)
  26.  
  27. #define STRN_AOMLabels                (128)
  28. #define STRN_BrowsePanelHelpStrings    (129)
  29. #define STRN_PDPanelHelpStrings        (130)
  30. #define    STRN_FindPanelHelpStrings    (131)
  31.  
  32. #define HELP_Resource        (0)        /* TBS */
  33.  
  34. #ifndef REZ
  35. #ifndef THINK_C                /* MPW includes            */
  36. #include <Processes.h>
  37. #include <Errors.h>
  38. #include <Finder.h>
  39. #include <Folders.h>
  40. #include <Script.h>
  41. #include <Types.h>
  42. #include <Resources.h>
  43. #include <QuickDraw.h>
  44. #include <Fonts.h>
  45. #include <Events.h>
  46. #include <Windows.h>
  47. #include <Menus.h>
  48. #include <TextEdit.h>
  49. #include <Dialogs.h>
  50. #include <Desk.h>
  51. #include <ToolUtils.h>
  52. #include <Memory.h>
  53. #include <Files.h>
  54. #include <OSUtils.h>
  55. #include <OSEvents.h>
  56. #include <DiskInit.h>
  57. #include <Packages.h>
  58. #include <Traps.h>
  59. #include <Lists.h>
  60. #endif
  61. #include <GestaltEqu.h>
  62. #include <OCE.h>
  63. #include <OCEAuthDir.h>
  64. #include <OCEStandardDirectory.h>
  65. #include <OCEErrors.h>
  66. /*
  67.  * OCEStandardMail is not used - it's here to simplify browsing
  68.  * the header files from the Think C editor.
  69.  */
  70. #include <OCEStandardMail.h>
  71. #include "AddressOMatic.h"
  72. #include "LogManager.h"
  73.  
  74. #ifndef EXTERN
  75. #define EXTERN                extern
  76. #endif
  77. #ifndef TRUE
  78. #define TRUE                1
  79. #define FALSE                0
  80. #endif
  81. #ifndef NULL
  82. #define NULL                0
  83. #endif
  84. #ifndef topLeft
  85. #define topLeft(rect)    (((Point *) &(rect))[0])
  86. #define botRight(rect)    (((Point *) &(rect))[1])
  87. #endif
  88.  
  89. #ifndef __CharCodesDefined__
  90. #define __CharCodesDefined__
  91. enum {                                        /* Keyboard commands    */
  92.     NUL                    = 0,
  93.     kOpenDoubleQuote    = 0xD2,
  94.     kCloseDoubleQuote    = 0xD3,
  95.     kOpenSingleQuote    = 0xD4,
  96.     kCloseSingleQuote    = 0xD5,
  97.     /* */
  98.     charEnter            = 0x03,                /* Enter key            */
  99.     charEscape            = 0x1B,
  100.     charHome            = 0x01,                /* Extended keyboard    */
  101.     charEnd                = 0x04,
  102.     charArrowLeft        = 0x1C,
  103.     charArrowRight        = 0x1D,
  104.     charArrowUp            = 0x1E,
  105.     charArrowDown        = 0x1F,
  106.     charPageUp            = 0x0B,
  107.     charPageDown        = 0x0C,
  108.     charHelp            = 0x05
  109. };
  110. enum {                                        /* Scroll bar constants    */
  111.     kScrollBarWidth     = 16,
  112.     kScrollBarOffset    = kScrollBarWidth - 1,
  113.     kScrollBarTweek        = 2                    /* Don't ask            */
  114. };
  115. enum {
  116.     kInvisibleCtrl        = 0,                /* contrlVis values        */
  117.     kVisibleCtrl        = 0xFF
  118. };
  119. #endif
  120. #define MakeControlVisible(ctrl)    ((**ctrl).contrlVis = kVisibleCtrl)
  121. #define MakeControlInvisible(ctrl)    ((**ctrl).contrlVis = kInvisibleCtrl)
  122. /*
  123.  * This defines the height of the non-browser stuff. These
  124.  * occupy fixed areas below the browser.
  125.  */
  126. #define kDestinationHeight    128
  127. #define kErrorLogHeight        64
  128. #define kSlop                 4
  129. #define kPrivateWidth        (kScrollBarWidth * 2)
  130. #define kPrivateHeight        \
  131.     (kDestinationHeight + kErrorLogHeight + kScrollBarWidth + kSlop * 3)
  132.     
  133. typedef struct BrowserRecord {
  134.     WindowRecord                window;
  135.     AddressOMaticPtr            aomPtr;
  136.     AuthIdentity                userIdentity;
  137.     ListHandle                    recipientLog;
  138.     ListHandle                    errorLogList;
  139.     unsigned short                selectionSize;
  140.     PackedDSSpecPtr                selection;
  141.     SMPRecipientDescriptorPtr    recipientList;
  142.     AOMPanelState                whatHappened;
  143.     Boolean                        wasFinding;
  144.     Rect                        panelRect;
  145.     Rect                        destRect;
  146.     Rect                        logRect;
  147. } BrowserRecord, *BrowserPtr;
  148. #define BROWSER        (*browserPtr)
  149. #define WINDOW        (BROWSER.window)
  150. #define PANEL        (BROWSER.aomPtr)
  151. #define ERROR_LOG    (BROWSER.errorLogList)
  152. #define    RESULT_LOG    (BROWSER.recipientLog)
  153.  
  154. /*
  155.  * This structure is used to dump the contents of a DSSpec. To
  156.  * use this, call UnpackPackedDSSpec with the packed DSSpec
  157.  * and a pointer to the buffer to unpack it into. Then call
  158.  * DisplayUnpackedDSSpec to display the contents of the unpacked
  159.  * buffer, and, finally, DisposeDSSpecDumpRecord to delete the
  160.  * temporary data stored in the DSSpecDumpRecord. Note: do not
  161.  * dispose of the packed DSSpec before disposing of the dump
  162.  * record as it contains direct pointers into the packed DSSpec.
  163.  */
  164. typedef struct DSSpecDumpRecord {
  165.     DSSpec                theDSSpec;
  166.     RecordID            recordID;
  167.     OSType                specType;
  168.     RLI                    theDSSpecRLI;
  169.     unsigned short        nodeNameCount;
  170.     unsigned short        unpackedNodeNameCount;
  171.     RStringPtr            *partsVector;
  172.     /*
  173.      * These Boolean values record the status of the DSSpec. They
  174.      * are TRUE if their associated part of the structure is
  175.      * present and in good condition.
  176.      */
  177.     Boolean                isValidDSSpec;
  178.     Boolean                isNonNullRLI;
  179.     Boolean                isValidPackedRLI;
  180.     Boolean                isValidPackedPathName;
  181.     Boolean                isValidPartsVector;
  182.     Boolean                isValidUnpackedNodeNameCount;
  183. } DSSpecDumpRecord, *DSSpecDumpPtr;
  184.  
  185.  
  186. /*
  187.  * Write data to the result log
  188.  */
  189. #define NOTE(msg)  do {                                    \
  190.         DisplayLogString(BROWSER.recipientLog, (msg));    \
  191.     } while (0)
  192. #define LOG_OSType(msg, ostype) do {                    \
  193.         Str255                    __work;                    \
  194.         OSType                    __datum;                \
  195.         unsigned char            __value[5];                \
  196.         pstrcpy(__work, (msg));                            \
  197.         __datum = (ostype);                                \
  198.         BlockMove(&__datum, &__value[1], sizeof (OSType)); \
  199.         __value[0] = sizeof (OSType);                    \
  200.         pstrcat(__work, "\p = '");                        \
  201.         pstrcat(__work, __value);                        \
  202.         pstrcat(__work, "\p'");                            \
  203.         DisplayLogString(BROWSER.recipientLog, __work);    \
  204.     } while (0)
  205. #define LOG_Value(msg, data) do {                        \
  206.         Str255                    __work;                    \
  207.         Str15                    __value;                \
  208.         pstrcpy(__work, (msg));                            \
  209.         NumToString((data), __value);                    \
  210.         pstrcat(__work, "\p = ");                        \
  211.         pstrcat(__work, __value);                        \
  212.         DisplayLogString(BROWSER.recipientLog, __work);    \
  213.     } while (0)
  214.  
  215. #define LOG_RString(msg, data) do {                    \
  216.         Str255                    __work;                    \
  217.         pstrcpy(__work, (msg));                            \
  218.         pstrcat(__work, "\p “");                        \
  219.         pstrcat(__work, OCERToPString((data)));            \
  220.         pstrcat(__work, "\p”");                            \
  221.         DisplayLogString(BROWSER.recipientLog, __work);    \
  222.     } while (0)
  223.  
  224. BrowserPtr                            IsOurWindow(
  225.         WindowPtr                        theWindow
  226.     );
  227. void                                BalloonHelp(
  228.         register WindowPtr                theWindow
  229.     );
  230. /*
  231.  * AddressOMatic test functions
  232.  */
  233. void                                DecorateWindow(
  234.         register BrowserPtr                browserPtr
  235.     );
  236. void                                DisposeAddressOMatic(
  237.         register BrowserPtr                browserPtr
  238.     );
  239.  
  240. void                                UnpackPackedDSSpec(
  241.         register BrowserPtr                browserPtr,
  242.         PackedDSSpecPtr                    packedDSSpecPtr,
  243.         register DSSpecDumpPtr            theDSSpecDumpPtr
  244.     );
  245. void                                DisplayUnpackedDSSpec(
  246.         register BrowserPtr                browserPtr,
  247.         register DSSpecDumpPtr            theDSSpecDumpPtr
  248.     );
  249. void                                DisposeDSSpecDumpRecord(
  250.         register BrowserPtr                browserPtr,
  251.         register DSSpecDumpPtr            theDSSpecDumpPtr
  252.     );
  253.  
  254. /*
  255.  * Window utilities (not specific to AddressOMatic Test)
  256.  */
  257. void                                DoZoomWindow(
  258.         WindowPtr                        theWindow,
  259.         short                            whichPart
  260.     );
  261. Boolean                                DoGrowWindow(
  262.         WindowPtr                        theWindow,
  263.         short                            minimumWidth,
  264.         short                            minimumHeight
  265.     );
  266. void                                MyDrawGrowIcon(
  267.         WindowPtr                        theWindow
  268.     );
  269.  
  270. /*
  271.  * User identity and AOCE utilities.
  272.  */
  273. void                                SetSpecificIdentity(
  274.         register BrowserPtr                browserPtr
  275.     );
  276. OSErr                                SystemSupportsAOCE(void);
  277.  
  278. void                                ClearMemory(
  279.         register void                    *recordPtr,
  280.         register Size                    recordSize
  281.     );
  282. #define CLEAR(what)    ClearMemory(&what, sizeof what)
  283. void                                ErrorAlert(
  284.         short                            alrtResId,
  285.         OSErr                            errorValue,
  286.         ConstStr255Param                errorText
  287.     );
  288. /*
  289.  * Cheap 'n dirty pascal string copy routine.
  290.  */
  291. #define pstrcpy(dst, src) do {                            \
  292.         StringPtr    _src = (src);                        \
  293.         BlockMove(_src, dst, _src[0] + 1);                \
  294.     } while (0)
  295. /*
  296.  * Cheap 'n dirty pascal string concat.
  297.  */
  298. #define pstrcat(dst, src) do {                            \
  299.         StringPtr        _dst = (dst);                    \
  300.         StringPtr        _src = (src);                    \
  301.         short            _len;                            \
  302.         _len = 255 - _dst[0];                            \
  303.         if (_len > _src[0]) _len = _src[0];                \
  304.         BlockMove(&_src[1], &_dst[1] + _dst[0], _len);    \
  305.         _dst[0] += _len;                                \
  306.     } while (0)
  307. #define appendchar(dst, ch)    ((dst)[++((dst)[0]) & 0xFF] = (ch))
  308. #define width(r)    ((r).right - (r).left)
  309. #define height(r)    ((r).bottom - (r).top)
  310.  
  311. /*
  312.  * Dialog Management
  313.  */
  314. void                        PositionDialog(
  315.         ResType                    dialogType,
  316.         short                    dialogID
  317.     );
  318. void                        PositionRect(
  319.         Rect                    *boundsPtr
  320.     );
  321.  
  322. /*
  323.  * Global definitions
  324.  */
  325. EXTERN MenuHandle                    gAppleMenu;
  326. EXTERN MenuHandle                    gFileMenu;
  327. EXTERN MenuHandle                    gEditMenu;
  328. EXTERN Boolean                        gQuitNow;
  329. EXTERN Boolean                        gUpdateMenusNeeded;
  330. EXTERN EventRecord                    gEventRecord;
  331. #define EVENT                        (gEventRecord)
  332. EXTERN BrowserPtr                    gCurrentBrowser;
  333. EXTERN ListHandle                    gCurrentLog;
  334. EXTERN short                        gOpenWindowCount;
  335. EXTERN Str255                        gFailureLocation;
  336. EXTERN Boolean                        gFindInProgress;
  337. /*
  338.  * Gestalt responses
  339.  */
  340. EXTERN Boolean                        gSystemHasBalloonHelp;
  341. EXTERN Boolean                        gHasColorQuickDraw;
  342. EXTERN Boolean                        gHasPopupCDEF;
  343. EXTERN Boolean                        gHasAOCEToolbox;
  344.  
  345.  
  346. #endif /* Not REZ */
  347. /*
  348.  * The following information is common to the application
  349.  * and the Rez source.
  350.  */
  351. #endif    /* _AddressOMaticTest_    */
  352.